<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/common/taglibs.jsp"%>
<link rel="stylesheet" type="text/css" href="${ctx}/styles/wish.css" media="screen"/>
<script type="text/javascript" src="${ctx}/scripts/wishstar.js"></script>
<div style="clear:both;height:650px;">
<div id="wish_left" class="wish_view">
</div>
<div class="wish_right">
	<div class="wish_tit">
		<table>
			<tr>
			<td style="width:150px;height:50px;align:center;">
			<select id="s_wishtypeid" name="wtid">
				<option>---选择愿望类型---</option>
				<c:forEach var="wtype" items="${types}">
					<option value="${wtype.typeid}" <c:if test="${wtype.typeid==wtid}">selected="selected"</c:if> ><c:out value="${wtype.name}"/></option>
				</c:forEach>
			</select>
			<a style="text-decoration:underline;color:#F00;" class="a2" id="a_wish_go_view" href="javascript:goViewWishByType()">GO</a>&nbsp;&nbsp;
			<a style="text-decoration:underline;color:#F00;"class="a2" id="a_wish_make" href="javascript:makeWish()">许愿</a>&nbsp;&nbsp;
			</td>
			<td style="width:600px;height:50px;color:#FFFFFF">
				<jsp:include page="/common/pager.jsp" />
			</td>
			</tr>
		</table>
	</div>
	<div id="wishContainer" class="wish-container">
	</div>
</div>
</div>
<script>
function goViewWishByType(){
	var wtid = $("#s_wishtypeid").val();
	window.location.href=ctx + "/wish/index.do?wtid="+wtid;
}
function makeWish(){
	var isLogin = '<c:out value="${isLogin}"/>';
	if(isLogin == 'false'){
		alert("请登录");
		return;
	}
	var wtid = $("#s_wishtypeid").val();
	$.fn.colorbox({
		 transition:"elastic",
		 width:"400px", 
		 height:"500px",
		 scrolling:false,
		 close:"关闭",
		 href:ctx +"/wish/tomake.do?wtid=" + wtid
		 });
}

//add wish star
var wishstargroup = new WishStarGroup($("#wishContainer"));
var wishesDataArray = ${wishesDataArray};
//[{wishid:1,userid:1,typeid:1,tips:"star1"},{}]
for (var i = 0; i < wishesDataArray.length; i++) {
	var star = new WishStar(wishstargroup, wishesDataArray[i]);
	star.addListener("onClick", {onClick:function (star, evt) {
		showWish(star.getProperty("wishid"));
	}});
}
//WishStarGroup.calcStarPosition(wishstargroup);
WishStarGroup.calcStarPosition('${wishType.position}', wishstargroup);

function showWish(wishid, index){
	var array = {};
	array['wid'] = wishid;
	array['wdex'] = index;
	tkra.htmlAjax(ctx+"/wish/get.do", array, "#wish_left");
}
$(document).ready(function(){showWish('${wid}')});
</script>